/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package acervo.connection;

import acervo.util.Erro;
import java.sql.*;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Fernando
 */
public class Conexao {

    public static Conexao conexao;
    public Connection con = null;

    public Connection getCon() {
        return con;
    }

    public static Conexao getConexao() {
        if (conexao == null) {
            conexao = new Conexao();
        }
        return conexao;
    }

    public Conexao() {
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=Acervo;user=sa;password=ueg;");
        } catch (SQLException ex) {
           Erro.LançarErro("Erro ao conectar com o banco.");
        } catch (ClassNotFoundException ex) {
            JOptionPane.showMessageDialog(null, "Driver não encontrado!");
        }

    }
}
